package com.authManager.server;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class Swaggers {
	private static final Logger log = LoggerFactory.getLogger(Swaggers.class);

	public Swaggers() {
		log.info("初始化Swagger");
	}

	@Bean
	public Docket api() {
		log.info("启动了 swaager");
		return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo("authManager", "authManager接口", "1")).groupName("authManager")
				.select()
				// 自行修改为自己的包路径
				.apis(RequestHandlerSelectors.basePackage("com.authManager.server.controller")).paths(PathSelectors.any())
				.build();
	}

	private ApiInfo apiInfo(String name, String description, String version) {
		ApiInfo apiInfo = new ApiInfoBuilder().title(name).description(description).version(version).build();
		return apiInfo;
	}
}
